Component({
  data:{
    selected: null,
    color: "#344256",
    selectedColor: "#288DF8",
    list: [
      {
        pagePath: '/pages/index/index',
        iconPath: '/assets/imgs/home.svg',
        selectedIconPath: '/assets/imgs/home-active.svg',
        title: '首页'
      },
      {
        pagePath: '/pages/my/my',
        iconPath: '/assets/imgs/my.svg',
        selectedIconPath: '/assets/imgs/my-active.svg',
        title: '我的'
      }
    ]
  },
  attached(){
    let id = getApp().globalData.userId;
    if(id == 1){
      this.switchToAdmin();
    }
  },
  methods: {
    switchToAdmin(){
      this.setData({
        list: [{
          pagePath: '/pages/index/index',
          iconPath: '/assets/imgs/home.svg',
          selectedIconPath: '/assets/imgs/home-active.svg',
          title: '首页'
        }]
      });
    },
    switchToUnit(){
      this.setData({
        list: [
          {
            pagePath: '/pages/index/index',
            iconPath: '/assets/imgs/home.svg',
            selectedIconPath: '/assets/imgs/home-active.svg',
            title: '首页'
          },
          {
            pagePath: '/pages/my/my',
            iconPath: '/assets/imgs/my.svg',
            selectedIconPath: '/assets/imgs/my-active.svg',
            title: '我的'
          }
        ]
      });
    },
    switchTab(e){
      const data = e.currentTarget.dataset;
      const url = data.path;
      wx.switchTab({url});
    }
  }
})